﻿namespace Smart.ERP
{
    using Smart.Data.Helper;
    using System;
    using System.Data.SqlClient;

    internal class KEYCODE
    {
        private int m_Activated;
        private bool m_Blacklist;
        private DateTime m_DateCreate;
        private DateTime m_DateLimit;
        private int m_Id_Contact;
        private int m_Id_Key;
        private string m_KeyCode;
        private int m_NumActive;
        private string m_Property;
        private bool m_Register;
        private int m_TypeActive;
        private int m_TypeSoft;

        public KEYCODE()
        {
            this.m_Id_Key = 0;
            this.m_KeyCode = "";
            this.m_Id_Contact = 0;
            this.m_DateCreate = DateTime.Now;
            this.m_Property = "";
            this.m_NumActive = 0;
            this.m_Activated = 0;
            this.m_Blacklist = true;
            this.m_TypeActive = 0;
            this.m_TypeSoft = 0;
            this.m_DateLimit = DateTime.Now;
            this.m_Register = true;
        }

        public KEYCODE(int Id_Key, string KeyCode, int Id_Contact, DateTime DateCreate, string Property, int NumActive, int Activated, bool Blacklist, int TypeActive, int TypeSoft, DateTime DateLimit, bool Register)
        {
            this.m_Id_Key = Id_Key;
            this.m_KeyCode = KeyCode;
            this.m_Id_Contact = Id_Contact;
            this.m_DateCreate = DateCreate;
            this.m_Property = Property;
            this.m_NumActive = NumActive;
            this.m_Activated = Activated;
            this.m_Blacklist = Blacklist;
            this.m_TypeActive = TypeActive;
            this.m_TypeSoft = TypeSoft;
            this.m_DateLimit = DateLimit;
            this.m_Register = Register;
        }

        public string Get(string KeyCode)
        {
            string str = "";
            string[] myParams = new string[] { "@KeyCode" };
            object[] myValues = new object[] { KeyCode };
            SqlHelper helper = new SqlHelper("HPqrGX/piQz0Xe4u/h/67gQ3uyF/l8Jnvceflfn0g5a097J0Dujgoj8bqG7F7buoYB2Mt+NKyXJ77rNdpJJ69tNga+CVb/KOMzARhvb5JWkXymCWnUJWzzgLCgblpEMy", "07071983", true);
            SqlDataReader reader = helper.ExecuteReader("KEYCODE_GetByKeyCode", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_Id_Key = Convert.ToInt32(reader["Id_Key"]);
                    this.m_KeyCode = Convert.ToString(reader["KeyCode"]);
                    this.m_Id_Contact = Convert.ToInt32(reader["Id_Contact"]);
                    this.m_DateCreate = Convert.ToDateTime(reader["DateCreate"]);
                    this.m_Property = Convert.ToString(reader["Property"]);
                    this.m_NumActive = Convert.ToInt32(reader["NumActive"]);
                    this.m_Activated = Convert.ToInt32(reader["Activated"]);
                    this.m_Blacklist = Convert.ToBoolean(reader["Blacklist"]);
                    this.m_TypeActive = Convert.ToInt32(reader["TypeActive"]);
                    this.m_TypeSoft = Convert.ToInt32(reader["TypeSoft"]);
                    this.m_DateLimit = Convert.ToDateTime(reader["DateLimit"]);
                    this.m_Register = Convert.ToBoolean(reader["Register"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public int Activated
        {
            get
            {
                return this.m_Activated;
            }
            set
            {
                this.m_Activated = value;
            }
        }

        public bool Blacklist
        {
            get
            {
                return this.m_Blacklist;
            }
            set
            {
                this.m_Blacklist = value;
            }
        }

        public DateTime DateCreate
        {
            get
            {
                return this.m_DateCreate;
            }
            set
            {
                this.m_DateCreate = value;
            }
        }

        public DateTime DateLimit
        {
            get
            {
                return this.m_DateLimit;
            }
            set
            {
                this.m_DateLimit = value;
            }
        }

        public int Id_Contact
        {
            get
            {
                return this.m_Id_Contact;
            }
            set
            {
                this.m_Id_Contact = value;
            }
        }

        public int Id_Key
        {
            get
            {
                return this.m_Id_Key;
            }
            set
            {
                this.m_Id_Key = value;
            }
        }

        public string KeyCode
        {
            get
            {
                return this.m_KeyCode;
            }
            set
            {
                this.m_KeyCode = value;
            }
        }

        public int NumActive
        {
            get
            {
                return this.m_NumActive;
            }
            set
            {
                this.m_NumActive = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class KEYCODE";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        public string Property
        {
            get
            {
                return this.m_Property;
            }
            set
            {
                this.m_Property = value;
            }
        }

        public bool Register
        {
            get
            {
                return this.m_Register;
            }
            set
            {
                this.m_Register = value;
            }
        }

        public int TypeActive
        {
            get
            {
                return this.m_TypeActive;
            }
            set
            {
                this.m_TypeActive = value;
            }
        }

        public int TypeSoft
        {
            get
            {
                return this.m_TypeSoft;
            }
            set
            {
                this.m_TypeSoft = value;
            }
        }
    }
}

